import axios from "axios"
import { MessageBox,Message } from "element-ui"

let http=axios.create({
    withCredentials:true,
    baseURL:"/api",
    timeout:5000,
})


http.interceptors.request.use(config=>{
    // console.log(config.headers.cccc="dddd")
return config
})

http.interceptors.response.use(config=>{
    // console.log(config)
    // 嵌套解构
    let{data:{state,msg}}=config;
    if(!state){
        // confirm是从element-ui里有的，所以需要引入
        MessageBox.alert(msg,'错误提示',{type:"error"})
    }
    return config
})   
export default http;